package chen.videoedit;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ImageView;

public class ScreenshotActivity extends BasisActivity {


    private String video;
    private ImageView img_view;
    private int i;

    @Override
    public int setlayoutResID() {
        return R.layout.activity_screenshot;
    }

    @Override
    public void initialView(Bundle arg0) {
        img_view=(ImageView)findViewById(R.id.activity_screenshot_iv);
       findViewById(R.id.activity_screenshot_bt).setOnClickListener(this);

    }

    @Override
    public void setActivity() {
        video = Environment.getExternalStorageDirectory().getPath() + "/1.mp4";//视频
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){

            case R.id.activity_screenshot_bt:
                createMediaMetadataRetriever();
                break;

        }

    }

    /**
     * 创建MediaMetadataRetriever对象
     */
    private void createMediaMetadataRetriever() {
        MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
        metadataRetriever.setDataSource(video);
        Bitmap bitmap = metadataRetriever.getFrameAtTime(i);
        i+=1000000;
        img_view.setImageBitmap(bitmap);

    }
}
